package com.woniu.deal.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.common.entity.DealUseraccount;
import com.woniu.deal.order.service.DealUseraccountService;
import com.woniu.deal.order.mapper.DealUseraccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
* @author Administrator
* @description 针对表【deal_useraccount】的数据库操作Service实现
* @createDate 2024-08-01 15:22:09
*/
@Service
public class DealUseraccountServiceImpl extends ServiceImpl<DealUseraccountMapper, DealUseraccount>
    implements DealUseraccountService{

    @Autowired
    DealUseraccountMapper dealUseraccountMapper;
    @Override
    public Integer createUserAccount(Integer id) {
        DealUseraccount dealUseraccount = new DealUseraccount(null,id,new BigDecimal(0));
        dealUseraccountMapper.insert(dealUseraccount);
        return dealUseraccount.getUseraccountId();
    }

    @Override
    public BigDecimal selectBalanceById(int id) {
        DealUseraccount dealUseraccount = dealUseraccountMapper.selectByUserId(id);
        return dealUseraccount.getUseraccountBalance();
    }

    @Override
    public DealUseraccount getByUserId(Integer userId) {
        return dealUseraccountMapper.selectByUserId(userId);
    }
}




